package com.peanut.sql.lineage.postgresql;

import java.util.List;
import java.util.Objects;

/****
 author:yifan
 date:2016
 description:
 **/
public class Table extends Vertex {
    private String tableName;
    private Database database;
    private Schema schema;
    private List<Column> columns;

    public Table(String tableName, Database database, Schema schema, List<Column> columns) {
        this.tableName = tableName;
        this.database = database;
        this.schema = schema;
        this.columns = columns;
    }

    public Table() {
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public Database getDatabase() {
        return database;
    }

    public void setDatabase(Database database) {
        this.database = database;
    }

    public Schema getSchema() {
        return schema;
    }

    public void setSchema(Schema schema) {
        this.schema = schema;
    }

    public List<Column> getColumns() {
        return columns;
    }

    public void setColumns(List<Column> columns) {
        this.columns = columns;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Table table = (Table) o;
        return Objects.equals(tableName, table.tableName) &&
                Objects.equals(database, table.database) &&
                Objects.equals(schema, table.schema) &&
                Objects.equals(columns, table.columns);
    }

    @Override
    public int hashCode() {
        return Objects.hash(tableName, database, schema, columns);
    }

    @Override
    public String toString() {
        return database + "." + schema + "." + tableName;
    }
}
